package com.tools.module.base.web;

import com.tools.common.config.AbstractController;
import com.tools.common.model.Result;
import com.tools.common.util.DateUtils;
import com.tools.common.util.ShiroUtils;
import com.tools.module.base.entity.BasePeople;
import com.tools.module.base.service.BasePeopleService;
import com.tools.module.base.service.impl.UploadFileService;
import com.tools.module.sys.entity.SysUser;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/base/people")
public class BasePeopleController extends AbstractController {

    @Autowired
    private BasePeopleService peopleService;
    @Autowired
    private UploadFileService uploadFileService;

    /**
     * 列表
     */
    @PostMapping("/list")
    public Result list(BasePeople people){
        return peopleService.list(people);
    }
    /**
     * 查询
     */
    @PostMapping("/get")
    public Result get(Long id){
        return peopleService.get(id);
    }
    /**
     * 保存
     */
    @PostMapping("/save")
    public Result save(@RequestBody BasePeople people){
        if (people.getId()==null){
            people.setCreateTime(DateUtils.getTimestamp());
            people.setCreateUid(ShiroUtils.getUserId());
        }
        people.setUpdateUid(ShiroUtils.getUserId());
        return peopleService.save(people);
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public Result delete(Long id){
        return peopleService.delete(id);
    }
}
